package com.zoagroup.funzy.entity;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;


/**
 * The persistent class for the type_atv database table.
 * 
 */
@Entity
@Table(name="type_atv")
public class TypeAtv implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="id_type_atv", unique=true, nullable=false)
	private Integer idTypeAtv;

	private String description;

	//bi-directional many-to-one association to Activity
	@OneToMany(mappedBy="typeAtvBean",cascade=CascadeType.ALL,fetch=FetchType.LAZY)
	private List<Activity> activities;

	public TypeAtv() {
	}

	public Integer getIdTypeAtv() {
		return this.idTypeAtv;
	}

	public void setIdTypeAtv(Integer idTypeAtv) {
		this.idTypeAtv = idTypeAtv;
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public List<Activity> getActivities() {
		return this.activities;
	}

	public void setActivities(List<Activity> activities) {
		this.activities = activities;
	}

	public Activity addActivity(Activity activity) {
		if(activities == null) {
			activities = new LinkedList<Activity>();
		}
		getActivities().add(activity);
		activity.setTypeAtvBean(this);

		return activity;
	}

	public Activity removeActivity(Activity activity) {
		if(activities == null) {
			activities = new LinkedList<Activity>();
		}
		getActivities().remove(activity);
		activity.setTypeAtvBean(null);

		return activity;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((idTypeAtv == null) ? 0 : idTypeAtv.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		TypeAtv other = (TypeAtv) obj;
		if (idTypeAtv == null) {
			if (other.idTypeAtv != null)
				return false;
		} else if (!idTypeAtv.equals(other.idTypeAtv))
			return false;
		return true;
	}
}